import { notification } from 'antd';
import { call, takeEvery } from 'redux-saga/effects';
import api from '../../api/api';
import sagaTypes from './sagaTypes';

function* addAuth(action) {
  const { data: res } = yield call(api.rolesAPIs.addAuth, action.payload);
  if (res.code) {
    notification['success']({
      message: '修改成功',
      description: '修改用户权限成功',
    });
  }
}

function* watchRoles() {
  yield takeEvery(sagaTypes.ADD_AUTH_ASYNC, addAuth);
}

export default watchRoles;
